package com.sk.controller;


import com.sk.entity.Equipment;
import com.sk.service.IEquipmentService;
import com.sk.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-05-27
 */
@RestController
@RequestMapping("/equipment")
public class EquipmentController {
     @Autowired
    private IEquipmentService equipmentService;

    //根据id 查询装备信息
    @GetMapping("{equipmentId}")
    public Result getById(@PathVariable("equipmentId") Integer equipmentId){
        return  equipmentService.getById(equipmentId);
    }

    //查询所有装备信息
    @GetMapping
    public  Result getAll(){
        Result result =equipmentService.getAll();
        return result;
    }


    //根据用户Id查询饰品信息
    @GetMapping("userId/{userId}")
    public  Result getByuserId(@PathVariable("userId")Integer userId){
        return  equipmentService.getByuserId(userId);
    }




    @GetMapping("type/{typeId}")
    public Result getByTypeId(@PathVariable("typeId") Integer typeId) {
        return equipmentService.getByTypeId(typeId);
    }



    @GetMapping("/name/{equipmentName}")
    public Result getByName(@PathVariable("equipmentName")String equipmentName){
        Result result = equipmentService.getByName(equipmentName);
        return result;
    }


    // 修改价格和状态（上架）
    @PutMapping("/update")
    public Result update(@RequestBody Equipment equipment) {
        return equipmentService.update(equipment);
    }


}
